<template>
  <div class="app-container">
    <Ht-search-form
      v-show="showSearch"
      :dictMap="dictMapAsync"
      :queryParams="queryParams"
      :outputQueryParams="queryParams"
      :formOptions="formOptions"
      :advOptions="[]"
      :defaultEventKey="defaultEventKey"
      :labelWidth="75"
    ></Ht-search-form>

    <!--    <div class="page-label-block">-->
    <!--      <span class="color-block">|</span>w-->
    <!--      <span class="page-label-name">-->
    <!--      租户管理-->
    <!--      </span>-->
    <!--    </div>-->

    <ht-table
      ref="dataTable"
      :multi-select="false"
      :showSerialNumber="false"
      :dictMap="dictMap"
      :queryParams="queryParams"
      :tableBindColumns="tableBindColumns"
      :opButtonList="opButtonList"
      :reqConfig="regConfig"
      :defaultEventKey="defaultEventKey"
      :randomRowKey="true"
    >
      <template v-slot:operate>
        <el-table-column label="操作" align="left" width="120" fixed="right">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
                {
                  label: '应答明细',
                   visible: (scope.row.status === '05'),
                  doFunc: () => {
                    handleAction('answerdetail', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog :title="title"  center :visible.sync="open" width="1024px" append-to-body :close-on-click-modal="false">
      <el-form ref="detailForm" :model="detailForm" :rules="rules" label-width="140px" :disabled="true">
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="流水号" prop="id">
              <el-input v-model="detailForm.id" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="原报文标识号" prop="pkgId">
              <el-input v-model="detailForm.pkgId" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="清算日期" prop="cpgdate">
              <el-date-picker v-model="detailForm.cpgdate" style="width: 100%" type="date" value-format="yyyyMMdd" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="工作日期" prop="workdate">
              <el-date-picker v-model="detailForm.workdate" style="width: 100%" type="date" value-format="yyyyMMdd" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="发起直接参与机构号" prop="directSender">
              <el-input v-model="detailForm.directSender" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="发起直接参与机构名称" prop="directSenderName">
              <el-input v-model="detailForm.directSenderName" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="接收直接参与机构号" prop="directRecver">
              <el-input v-model="detailForm.directRecver" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="接收直接参与机构名称" prop="directRecverName">
              <el-input v-model="detailForm.directRecverName" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="备注" prop="remarks">
              <el-input type="textarea" v-model="detailForm.remarks"/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="费用标识" prop="feeId">
              <el-select style="width: 100%" v-model="detailForm.feeId" placeholder="费用标识">
                <el-option
                  v-for="dict in dictMap.FEE_ID"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="统一社会信用代码" prop="uniformScCode">
              <el-input v-model="detailForm.uniformScCode" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="客户标识" prop="custId">
              <el-input v-model="detailForm.custId" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="客户标识类型" prop="custType">
              <el-select style="width: 100%" v-model="detailForm.custType" placeholder="客户标识类型">
                <el-option
                  v-for="dict in dictMap.Cust_Identy_Type_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="特约委收种类代码" prop="spTypeCode">
              <el-input v-model="detailForm.spTypeCode" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="账期区间" prop="billDate">
              <el-input v-model="detailForm.billDate" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="欠缴类型" prop="arrearsType">
              <el-select style="width: 100%" v-model="detailForm.arrearsType" placeholder="欠缴类型">
                <el-option
                  v-for="dict in dictMap.Arrears_Type_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="缴款渠道" prop="paymentType">
              <el-select style="width: 100%" v-model="detailForm.paymentType" placeholder="缴款渠道">
                <el-option
                  v-for="dict in dictMap.Pay_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="缴款查询类型" prop="paymentInqType">
              <el-select style="width: 100%" v-model="detailForm.paymentInqType" placeholder="缴款查询类型">
                <el-option
                  v-for="dict in dictMap.Pay_Query_Type_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="地域标识" prop="regionid">
              <el-select style="width: 100%;" v-model="detailForm.regionid" placeholder="地域标识">
                <el-option
                  v-for="dict in dictMap.RegionId"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="账单信息数目" prop="billNum">
              <el-input v-model="detailForm.billNum" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="附言" prop="addInfo">
              <el-input type="textarea" v-model="detailForm.addInfo" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="票据业务类型" prop="billType">
              <el-input v-model="detailForm.billType" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="票面校验信息" prop="billChkInfo">
              <el-input v-model="detailForm.billChkInfo" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="险种代码" prop="insuranceCode">
              <el-input v-model="detailForm.insuranceCode" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="单位社保号码" prop="orgSocialId">
              <el-input v-model="detailForm.orgSocialId" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="缴费人名称" prop="payerName">
              <el-input type="textarea" v-model="detailForm.payerName" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="缴费人证件类型" prop="payerIdType">
              <el-select style="width: 100%" v-model="detailForm.payerIdType" placeholder="缴费人证件类型">
                <el-option
                  v-for="dict in dictMap.Id_Type_Code"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="缴费人证件号码" prop="payerIdNo">
              <el-input v-model="detailForm.payerIdNo" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="原报文标识号" prop="oriPkgId">
              <el-input v-model="detailForm.oriPkgId" placeholder="原报文标识号" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="原发起参与机构" prop="oriSender">
              <el-input v-model="detailForm.oriSender" placeholder="原发起参与机构" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="原报文类型" prop="oriMsgType">
              <el-input v-model="detailForm.oriMsgType" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="征收机关代码" prop="orgId">
              <el-input v-model="detailForm.orgId" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="纳税人编码" prop="taxPayerCode">
              <el-input v-model="detailForm.taxPayerCode" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="交易状态" prop="status">
              <el-select style="width: 100%" v-model="detailForm.status" placeholder="交易状态">
                <el-option
                  v-for="dict in dictMap.PKG_STATUS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <ht-table
            ref="dataTableDetail"
            :multi-select="false"
            :showSerialNumber="false"
            :dictMap="dictMap"
            :queryParams="queryParamsDetail"
            :tableBindColumns="tableBindColumnsDetail"
            :opButtonList="opButtonList"
            :reqConfig="regConfigDetail"
            :showRightToolbar="false"
            :randomRowKey="true"
            :initData="false"
          />
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" align="center">
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>

    <!-- 添加或修改弹出框 -->
    <el-dialog
      :title="titleAnswer"
      :visible.sync="openAnswer"
      width="1024px"
      append-to-body
      :close-on-click-modal="false"
    >
      <el-form ref="detailAnswerForm" :model="detailAnswerForm" :rules="rules" label-width="140px" :disabled="true">
        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="交易流水号" prop="id">
              <el-input v-model="detailAnswerForm.id" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="报文标识号" prop="pkgId">
              <el-input v-model="detailAnswerForm.pkgId" :disabled="true" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="CPG日期" prop="cpgdate">
              <el-date-picker
                v-model="detailAnswerForm.cpgdate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="工作日期" prop="workdate">
              <el-date-picker
                v-model="detailAnswerForm.workdate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="发起直接参与机构号" prop="directSender">
              <el-input v-model="detailAnswerForm.directSender" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="发起直接参与机构名称" prop="directSenderName">
              <el-input v-model="detailAnswerForm.directSenderName" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="接收直接参与机构号" prop="directRecver">
              <el-input v-model="detailAnswerForm.directRecver" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="接收直接参与机构名称" prop="directRecverName">
              <el-input v-model="detailAnswerForm.directRecverName" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="发起类型" prop="sysCode">
              <el-select style="width: 100%" v-model="detailAnswerForm.sysCode" placeholder="发起类型">
                <el-option
                  v-for="dict in dictMap.SND_TP_CODE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="原报文标识号" prop="oriPkgId">
              <el-input v-model="detailAnswerForm.oriPkgId" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="原发起行行行号" prop="oriSender">
              <el-input v-model="detailAnswerForm.oriSender" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="原业务类型" prop="oriMsgType">
              <el-select
                style="width: 100%"
                v-model="
                  detailAnswerForm.oriMsgType === null || detailAnswerForm.oriMsgType === undefined
                    ? ''
                    : detailAnswerForm.oriMsgType + '-' + detailAnswerForm.oriMsgTypeDesc
                "
                placeholder="原业务类型"
                :disabled="true"
              ></el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="业务拒绝处理码" prop="bizRejectCode">
              <el-input v-model="detailAnswerForm.bizRejectCode" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="统一社会信用代码" prop="uniformScCode">
              <el-input v-model="detailAnswerForm.uniformScCode" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="业务拒绝信息" prop="bizRejectInfo">
              <el-input type="textarea" v-model="detailAnswerForm.bizRejectInfo" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="业务处理参与机构" prop="bizProOrg">
              <el-input v-model="detailAnswerForm.bizProOrg" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="费用标识" prop="feeId">
              <el-select style="width: 100%" v-model="detailAnswerForm.feeId" placeholder="费用标识">
                <el-option
                  v-for="dict in dictMap.FEE_ID"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="客户标识" prop="custId">
              <el-input type="textarea" v-model="detailAnswerForm.custId" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="客户名称" prop="custName">
              <el-input type="textarea" v-model="detailAnswerForm.custName" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="合同（协议）号" prop="protoId">
              <el-input type="textarea" v-model="detailAnswerForm.protoId" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="地域标识" prop="regionId">
              <el-select
                style="width: 100%"
                v-model="
                  detailAnswerForm.regionId === null || detailAnswerForm.regionId === undefined
                    ? ''
                    : detailAnswerForm.regionId + '-' + detailAnswerForm.regionIdDesc
                "
                placeholder="地域标识"
                :disabled="true"
              ></el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总账单编号" prop="billNo">
              <el-input v-model="detailAnswerForm.billNo" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="欠费总信息内容" prop="arrearsTotalInfo">
              <el-input type="textarea" v-model="detailAnswerForm.arrearsTotalInfo" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="欠费总金额币种" prop="arrearsTotalCurcd">
              <el-input v-model="detailAnswerForm.arrearsTotalCurcd" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="欠费总金额" prop="arrearsTotalAmt">
              <ht-amount-input
                v-model="detailAnswerForm.arrearsTotalAmt"
                placeholder="欠费总金额"
                :disable="true"
              ></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="总代扣手续费币种" prop="totalBillCurcd">
              <el-input v-model="detailAnswerForm.totalBillCurcd" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="总代扣手续费" prop="totalBill">
              <ht-amount-input
                v-model="detailAnswerForm.totalBill"
                placeholder="总代扣手续费"
                :disable="true"
              ></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="总其他扣费币种" prop="totalOtFeeCurcd">
              <el-input v-model="detailAnswerForm.totalOtFeeCurcd" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="总其他扣费" prop="totalOtFee">
              <ht-amount-input
                v-model="detailAnswerForm.totalOtFee"
                placeholder="总代扣手续费"
                :disable="true"
              ></ht-amount-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="客户地址" prop="custAddr">
              <el-input type="textarea" v-model="detailAnswerForm.custAddr" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="缴费信息数目" prop="paymentInfoNum">
              <el-input v-model="detailAnswerForm.paymentInfoNum" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="征收机关代码" prop="orgId">
              <el-input v-model="detailAnswerForm.orgId" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="征收机关名称" prop="orgName">
              <el-input type="textarea" v-model="detailAnswerForm.orgName" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="征收机关提交日期" prop="orgCmtDate">
              <el-date-picker
                v-model="detailAnswerForm.orgCmtDate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="征收机关流水号" prop="orgFlowNo">
              <el-input type="textarea" v-model="detailAnswerForm.orgFlowNo" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="国库代码" prop="nationalCode">
              <el-input v-model="detailAnswerForm.nationalCode" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="注册类型代码" prop="regCode">
              <el-input v-model="detailAnswerForm.regCode" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="纳税人编码" prop="taxPayerCode">
              <el-input v-model="detailAnswerForm.taxPayerCode" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="纳税人名称" prop="taxPayerName">
              <el-input type="textarea" v-model="detailAnswerForm.taxPayerName" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="税种名称" prop="taxName">
              <el-input type="textarea" v-model="detailAnswerForm.taxName" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="缴款单位名称" prop="payCmpName">
              <el-input type="textarea" v-model="detailAnswerForm.payCmpName" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="24">
            <el-form-item label="缴款流水号" prop="payFlowNo">
              <el-input type="textarea" v-model="detailAnswerForm.payFlowNo" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <el-col :span="12">
            <el-form-item label="截止日期" prop="endDate">
              <el-date-picker
                v-model="detailAnswerForm.endDate"
                style="width: 100%"
                type="date"
                value-format="yyyyMMdd"
              />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="业务状态" prop="bizStatus">
              <el-select style="width: 100%" v-model="detailAnswerForm.bizStatus" placeholder="业务状态">
                <el-option
                  v-for="dict in dictMap.TXN_STATUS"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row type="flex">
          <ht-table
            ref="dataTableDetail"
            :multi-select="false"
            :showSerialNumber="false"
            :dictMap="dictMap"
            :queryParams="queryParamsAnswerDetail"
            :tableBindColumns="tableBindColumnsAnswerDetail"
            :opButtonList="opButtonList"
            :reqConfig="regConfigAnswerDetail"
            :showRightToolbar="false"
            :randomRowKey="true"
            :initData="false"
          />
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" align="center">
        <el-button type="primary" @click="cancelAnswer">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listPageMixin } from "@/libs/listPageMixin";

import { amountThousandsFormatter } from "@/utils/table_col_formatter";
import {
  activePaymentManagementMessageQuery,
  activePaymentManagementMessageQueryDetail,
  activePaymentManagementMessageQueryDetailQuery,
  activePaymentManagementMessageQueryReplyDetail,
  activePaymentManagementMessageQueryReplyDetailQuery,
} from "@/api/cnaps/beps/361";
import HtAmountInput from "@/views/components/HtAmountInput";

export default {
  name: "ActivePaymentManagementMessageQuery",
  mixins: [listPageMixin],
  components: { HtAmountInput },
  data() {
    return {
      // 查询参数
      queryParams: {
        idSeqno: undefined,
        pkgId: undefined,
        startcpgdate: undefined,
        endcpgdate: undefined,
        startworkdate: undefined,
        endworkdate: undefined,
      },
      queryParamsDetail: {
        id: undefined,
      },
      queryParamsAnswerDetail: {
        id: "",
      },
      loading: false,
      // 搜索
      defaultEventKey: "defaultEventKey",
      formOptions: [],
      //
      searchFormDictList: [
        "FEE_ID",
        "PKG_STATUS",
        "Cust_Identy_Type_Code",
        "Arrears_Type_Code",
        "Pay_Code",
        "Pay_Query_Type_Code",
        "Id_Type_Code",
        "SND_TP_CODE",
        "TXN_STATUS",
        "RegionId"
      ],
      // 列信息
      regConfig: activePaymentManagementMessageQuery,

      regConfigDetail: activePaymentManagementMessageQueryDetailQuery,

      regConfigAnswerDetail: activePaymentManagementMessageQueryReplyDetailQuery,

      tableBindColumns: [
        { prop: "id", label: "流水号", width: 180 },
        { prop: "cpgdate", label: "清算日期", type: "date" },
        { prop: "workdate", label: "工作日期", type: "date" },
        { prop: "pkgId", label: "报文标识号", width: 180 },
        { prop: "feeId", label: "费用标识", dictCode: "FEE_ID", width: 180 },
        { prop: "uniformScCode", label: "统一社会信用代码", width: 180 },
        { prop: "status", label: "状态", dictCode: "PKG_STATUS" },
      ],

      tableBindColumnsDetail: [
        { prop: "billCode", label: "账单编号" },
        { prop: "billCurcd", label: "账单金额币种" },
        { prop: "billAmt", label: "账单金额", type: "price" },
      ],

      tableBindColumnsAnswerDetail: [
        { prop: "payeeStBrno", label: "收款清算行行号", width: 180 },
        { prop: "payeeBrno", label: "收款行行号", width: 180 },
        { prop: "payeeName", label: "收款人名称", width: 180 },
        { prop: "payeeActno", label: "收款人账号", width: 180 },
        { prop: "payeeAccBrno", label: "收款人开户行行号", width: 180 },
        { prop: "billCode", label: "账单编号", width: 180 },
        { prop: "billAmt", label: "账单金额", type: "price", width: 180 },
        { prop: "payAmt", label: "缴款金额", type: "price", width: 180 },
        { prop: "otFee", label: "其他扣费", type: "price", width: 180 },
        { prop: "serviceAmt", label: "手续费", width: 180 },
        { prop: "billDate", label: "账期区间", width: 180 },
        { prop: "paymentType", label: "主动缴费类别", dictCode: "Pay_Code", width: 180 },
      ],

      dictMapAsync: {},
      // 弹出层标题
      title: "",
      titleAnswer: "",
      // 是否显示弹出层
      open: false,
      openAnswer: false,
      // 表单参数
      detailForm: {},
      detailAnswerForm: {},

      totalRecord: 0,
      totalPage: 0,
      needCount: 0,

      rules: {},
    };
  },
  mounted() {
    const formOptions = [
      // 普通搜索

      {
        type: "input",
        prop: "idSeqno",
        defaultAttr: {
          size: "small",
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },

      {
        type: "input",
        prop: "pkgId",
        defaultAttr: {
          size: "small",
          label: "报文标识号",
          placeholder: "请输入报文标识号",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "startcpgdate",
          endTimeName: "endcpgdate",
        },
        defaultAttr: {
          size: "small",
          label: "CPG日期",
          placeholder: ["请输入CPG日期开始", "请输入CPG结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "startworkdate",
          endTimeName: "endworkdate",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作日期开始", "请输入工作结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },
    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */
    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
        case "answerdetail":
          this.handleAnswerDetail(row);
          break;
      }
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },

    cancelAnswer() {
      this.openAnswer = false;
    },

    /** 详情按钮操作 */
    handleDetail(row) {
      this.title = "主动缴款管理报文查询明细";
      activePaymentManagementMessageQueryDetail(row)
        .then((response) => {
          this.detailForm = response.result;
          this.queryParamsDetail.id = response.result.id;
          this.open = true;
          this.$nextTick(() => {
            this.$refs.dataTableDetail.doQuery();
          });
        })
        .catch((err) => {});
    },

    /** 详情按钮操作 */
    handleAnswerDetail(row) {
      this.titleAnswer = "主动缴款账单通知报文明细";
      activePaymentManagementMessageQueryReplyDetail(row)
        .then((response) => {
          this.detailAnswerForm = response.result;
          this.queryParamsAnswerDetail.id = response.result.id;
          this.openAnswer = true;
          this.$nextTick(() => {
            this.$refs.dataTableDetail.doQuery();
          });
        })
        .catch((err) => {});
    },
  },
};
</script>
